package fr.lium.spkDiarization.parameter;

import java.util.ArrayList;

import gnu.getopt.LongOpt;

public class ParameterDiarization implements ParameterInterface {
	public int ReferenceDiarization = -1;
	public int ReferenceAudioFileMask = -1;
	public int ReferenceCEClustering = -1;
	public int ReferenceSaveAllStep = -1;
	public int ReferenceLoadInputSegmentation = -1;

	private boolean CEClustering;
	private boolean saveAllStep;
	private boolean loadInputSegmentation;
	private String system;

	public ParameterDiarization(ArrayList<LongOpt> list, Parameter param) {
		CEClustering = false;
		saveAllStep = false;
		loadInputSegmentation = false;
		system = "current";
		ReferenceDiarization = param.getNextOptionIndex();
		ReferenceAudioFileMask = param.getNextOptionIndex();
		ReferenceCEClustering = param.getNextOptionIndex();
		ReferenceSaveAllStep = param.getNextOptionIndex();
		ReferenceLoadInputSegmentation = param.getNextOptionIndex();
		addOptions(list);
	}

	public boolean readParam(int option, String optarg) {
		if (option == ReferenceCEClustering) {
			setCEClustering(true);
			return true;
		} else if (option == ReferenceDiarization) {
			setSystem(optarg);
			return true;
		} else if (option == ReferenceSaveAllStep) {
			setSaveAllStep(true);
			return true;
		} else if (option == ReferenceLoadInputSegmentation) {
			setLoadInputSegmentation(true);
			return true;
		}
		return false;
	}

	public void addOptions(ArrayList<LongOpt> list) {
		list.add(new LongOpt("system", 1, null, ReferenceDiarization));
		list.add(new LongOpt("audioFile", 1, null, ReferenceAudioFileMask));
		list.add(new LongOpt("doCEClustering", 0, null, ReferenceCEClustering));
		list.add(new LongOpt("saveAllStep", 0, null, ReferenceSaveAllStep));
		list.add(new LongOpt("loadInputSegmentation", 0, null, ReferenceLoadInputSegmentation));
	}

	public boolean isCEClustering() {
		return CEClustering;
	}

	public boolean isLoadInputSegmentation() {
		return loadInputSegmentation;
	}

	public void printCEClustering() {
		System.out.println("info[ParameterSystem] \t --doCEClustering = " + isCEClustering());
	}

	public void printSystem() {
		System.out.println("info[ParameterSystem] \t --system = " + getSystem());
	}

	public void printSaveAllStep() {
		System.out.println("info[ParameterSystem] \t --saveAllStep = " + isSaveAllStep());
	}

	public void printLoadInputSegmentation() {
		System.out.println("info[ParameterSystem] \t --loadInputSegmentation = " + isLoadInputSegmentation());
	}

	public void print() {
		printSystem();
		printCEClustering();
		printSaveAllStep();
		printLoadInputSegmentation();
	}

	public void setSystem(String system) {
		this.system = system;
	}

	public void setCEClustering(boolean cEClustering) {
		CEClustering = cEClustering;
	}

	private void setLoadInputSegmentation(boolean b) {
		loadInputSegmentation = b;
	}

	public String getSystem() {
		return system;
	}

	public boolean isSaveAllStep() {
		return saveAllStep;
	}

	public void setSaveAllStep(boolean saveAllStep) {
		this.saveAllStep = saveAllStep;
	}
}
